package com.mindskip.xzs.domain;


import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.Date;
import java.util.regex.Pattern;

public class User implements Serializable {

    private static final long serialVersionUID = -7797183521247423117L;

    private Integer id;

    private String userUuid;

    /**
     * 用户名
     */
    private String userName;

    private String password;

    /**
     * 真实姓名
     */
    private String realName;

    public String getSexStr() {
        return sexStr;
    }

    public void setSexStr(String sexStr) {
        this.sexStr = sexStr;
    }

    private Integer age;

    /**
     * 1.男 2女
     */
    private Integer sex;

    /**
     * 性别对应
     */
    private String sexStr;


    /**
     * 出生年月
     */
    private Date birthDay;

    /**
     * 学员公司(1-12)
     */
    private Integer userLevel;

    /**
     * 班级
     */
    private String levelName;


    private String phone;

    /**
     * 1.学员  3.管理员
     */
    private Integer role;

    /**
     * 1.启用 2禁用
     */
    private Integer status;

    /**
     * 头像地址
     */
    private String imagePath;

    private Date createTime;

    private Date modifyTime;

    private Date lastActiveTime;

    /**
     * 是否删除
     */
    private Boolean deleted;

    /**
     * 微信openId
     */
    private String wxOpenId;


    /**
     * 名族
     */
    private String nationality;


    /**
     * 学历
     */
    private String education;


    /**
     * 身份证号码
     */
    private String idCardNo;


    /**
     * 户籍所在地
     */
    private String birthLocation;


    /**
     * 现地址
     */
    private String location;

    /**
     * 政治面貌
     */
    private String politics;


    /**
     * 身高
     */
    private String height;

    /**
     * 健康状况
     */
    private String health;


    /**
     * 兵役
     */
    private String army;


    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public String getNationality() {
        return nationality;
    }

    public void setNationality(String nationality) {
        this.nationality = nationality;
    }

    public String getEducation() {
        return education;
    }

    public void setEducation(String education) {
        this.education = education;
    }

    public String getIdCardNo() {
        return idCardNo;
    }

    public void setIdCardNo(String idCardNo) {
        this.idCardNo = idCardNo;
    }

    public String getBirthLocation() {
        return birthLocation;
    }

    public void setBirthLocation(String birthLocation) {
        this.birthLocation = birthLocation;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public String getPolitics() {
        return politics;
    }

    public void setPolitics(String politics) {
        this.politics = politics;
    }

    public String getHeight() {
        return height;
    }

    public void setHeight(String height) {
        this.height = height;
    }

    public String getHealth() {
        return health;
    }

    public void setHealth(String health) {
        this.health = health;
    }

    public String getArmy() {
        return army;
    }

    public void setArmy(String army) {
        this.army = army;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUserUuid() {
        return userUuid;
    }

    public void setUserUuid(String userUuid) {
        this.userUuid = userUuid == null ? null : userUuid.trim();
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName == null ? null : userName.trim();
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password == null ? null : password.trim();
    }

    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName == null ? null : realName.trim();
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Integer getSex() {
        return sex;
    }

    public void setSex(Integer sex) {
        this.sex = sex;
    }

    public Date getBirthDay() {
        return birthDay;
    }

    public void setBirthDay(Date birthDay) {
        this.birthDay = birthDay;
    }

    public Integer getUserLevel() {
        return userLevel;
    }

    public void setUserLevel(Integer userLevel) {
        this.userLevel = userLevel;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone == null ? null : phone.trim();
    }

    public Integer getRole() {
        return role;
    }

    public void setRole(Integer role) {
        this.role = role;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getImagePath() {
        return imagePath;
    }

    public void setImagePath(String imagePath) {
        this.imagePath = imagePath == null ? null : imagePath.trim();
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getModifyTime() {
        return modifyTime;
    }

    public void setModifyTime(Date modifyTime) {
        this.modifyTime = modifyTime;
    }

    public Date getLastActiveTime() {
        return lastActiveTime;
    }

    public void setLastActiveTime(Date lastActiveTime) {
        this.lastActiveTime = lastActiveTime;
    }

    public Boolean getDeleted() {
        return deleted;
    }

    public void setDeleted(Boolean deleted) {
        this.deleted = deleted;
    }

    public String getWxOpenId() {
        return wxOpenId;
    }

    public void setWxOpenId(String wxOpenId) {
        this.wxOpenId = wxOpenId == null ? null : wxOpenId.trim();
    }

    public String getLevelName() {
        return levelName;
    }

    public void setLevelName(String levelName) {
        this.levelName = levelName;
    }

    private static Pattern pattern = Pattern.compile("-?[0-9]+(\\\\.[0-9]+)?");


   public String getEducationStr(String key){
        if(StringUtils.isNotEmpty(key) && pattern.matcher(key).matches()){
            if("1".equals(key)){
                return "本科及以上";
            }
            if("2".equals(key)){
                return "专科";
            }
            if("3".equals(key)){
                return "高中";
            }
            if("4".equals(key)){
                return "初中";
            }
            if("5".equals(key)){
                return "小学";
            }
        }
        return key;
   }

    public String getPoliticsStr(String key){
        if(StringUtils.isNotEmpty(key) && pattern.matcher(key).matches()){
            if("1".equals(key)){
                return "党员";
            }
            if("2".equals(key)){
                return "团员";
            }
            if("3".equals(key)){
                return "群众";
            }
        }
        return key;
    }

    public String getArmyStr(String key){
        if(StringUtils.isNotEmpty(key) && pattern.matcher(key).matches()){
            if("1".equals(key)){
                return "未服兵役";
            }
            if("2".equals(key)){
                return "退出现役";
            }
            if("3".equals(key)){
                return "预备役";
            }
        }
        return key;
    }

    public String getSexStr(Integer key) {
       if(null == key){
           return "男";
       }
        if (1 == key) {
            return "男";
        }
        if (2 == key) {
            return "女";
        }
        return "男";
    }


    public  void getUserInfoDetail(User user) {
        user.setSexStr(getSexStr(user.getSex()));
        user.setArmy(getArmyStr(user.getArmy()));
        user.setPolitics(getPoliticsStr(user.getPolitics()));
        user.setEducation(getEducationStr(user.getEducation()));
    }
}
